package com.flyoil.petromp.ui.activity.activity_matter;

import android.content.Intent;
import android.support.v7.widget.GridLayoutManager;

import com.flyoil.petromp.R;
import com.flyoil.petromp.adapter.adapter_matter.ItemMatterAdapter;
import com.flyoil.petromp.adapter.adapter_matter.ItemMatterSearchConditionAdapter;
import com.flyoil.petromp.base.BaseActivity;
import com.flyoil.petromp.base.BaseRecyAdapter;
import com.flyoil.petromp.entity.entity_matter.MatterEntity;
import com.flyoil.petromp.entity.entity_matter.MatterSearchOrderConditionEntity;
import com.flyoil.petromp.utils.HintConstants;
import com.flyoil.petromp.utils.OrderUtl.OrderListUtil;
import com.flyoil.petromp.view.SearchDataView;

import java.util.ArrayList;
import java.util.List;

/**
 * 搜索事项列表数据的界面
 */
public class SearchOrderConditionActivity extends BaseActivity {
    private ItemMatterSearchConditionAdapter adapter;

    @Override
    protected int getContentViewResId() {
        return R.layout.activity_search_matter_data;
    }

    @Override
    protected void initViews() {
        super.initViews();
        setTextTitleName("筛选");
        recyclerView = $(R.id.list_search_order_condition);
        GridLayoutManager gridLayoutManager = new GridLayoutManager(mContext, 3);
        setRecyviewLayoutManager(gridLayoutManager);
        adapter = new ItemMatterSearchConditionAdapter(mContext);
        recyclerView.setAdapter(adapter);


    }

    @Override
    protected void initEvents() {
        super.initEvents();
        adapter.setOnItemClickListener(onItemClickListener);
        setBackOnclickListner(mContext);
    }

    /**
     * 列表item的点击事件
     */
    private BaseRecyAdapter.OnItemClickListener onItemClickListener = new BaseRecyAdapter.OnItemClickListener() {
        @Override
        public void Onclick(int position, Object data) {
            Intent intent = getIntent();
            intent.putExtra("billType", adapter.getData().get(position).getType());
            intent.putExtra("name", adapter.getData().get(position).getName());
            setResult(RESULT_OK, intent);
            backFinish();
        }
    };

    @Override
    protected void initdatas() {
        super.initdatas();
        List<MatterSearchOrderConditionEntity> data = new ArrayList<>();
        data.add(new MatterSearchOrderConditionEntity("全部", "", R.mipmap.matter_all_icon));
        data.add(new MatterSearchOrderConditionEntity("采购计划流程", OrderListUtil.PLAN, R.mipmap.matter_plan_icon));
        data.add(new MatterSearchOrderConditionEntity("物资采购需求", OrderListUtil.GOODS_DEMAND, R.mipmap.matter_goods_demand_icon));
        data.add(new MatterSearchOrderConditionEntity("物资采购审批", OrderListUtil.GOODS_APPROVE, R.mipmap.matter_goods_approve_icon));
        data.add(new MatterSearchOrderConditionEntity("物资采购订单", OrderListUtil.GOODS_ORDER, R.mipmap.matter_goods_order_icon));
        data.add(new MatterSearchOrderConditionEntity("物质采购验收", OrderListUtil.GOODS_EXAMINE, R.mipmap.matter_goods_examine_icon));
        data.add(new MatterSearchOrderConditionEntity("服务任务需求", OrderListUtil.SERVICE_DEMAND, R.mipmap.matter_service_demand_icon));
        data.add(new MatterSearchOrderConditionEntity("服务任务审批", OrderListUtil.SERVICE_APPROVE, R.mipmap.matter_service_approve_icon));
        data.add(new MatterSearchOrderConditionEntity("服务任务订单", OrderListUtil.SERVICE_ORDER, R.mipmap.matter_service_order_icon));
        data.add(new MatterSearchOrderConditionEntity("服务任务验收", OrderListUtil.SERVICE_EXAMINE, R.mipmap.matter_service_examine_icon));
        data.add(new MatterSearchOrderConditionEntity("付款申请", OrderListUtil.FINANCE, R.mipmap.matter_finance_icon));
        data.add(new MatterSearchOrderConditionEntity("供应商档案", OrderListUtil.REPERTORY_SUPPLIER, R.mipmap.matter_repertory_supplier_icon));
        data.add(new MatterSearchOrderConditionEntity("供应商物品", OrderListUtil.REPERTORY_PRODUCT, R.mipmap.matter_repertory_product_icon));
        data.add(new MatterSearchOrderConditionEntity("供应商服务", OrderListUtil.REPERTORY_SERVICE, R.mipmap.matter_repertory_service_icon));
        adapter.setDataList(data);
        recyclerView.notifyDataSetChanged();
    }
}
